package cevent.source.cloudcenter.business.controller.client;/**
 * Created by Cevent on 2021/7/29.
 */

import cevent.source.cloudcenter.server.dto.MemberDto;
import cevent.source.cloudcenter.server.dto.ResponseDataDto;
import cevent.source.cloudcenter.server.dto.ShortMessageDto;
import cevent.source.cloudcenter.server.service.MemberService;
import cevent.source.cloudcenter.server.service.ShortMessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author cevent
 * @description 客户端短信接口
 * @date 2021/7/29 17:31
 */
@RestController
@RequestMapping("/client/shortMessage")
public class ClientShortMessageController {

    private static final Logger LOG= LoggerFactory.getLogger(ClientShortMessageController.class);
    public static final String BUSINESS_NAME="客户端Short Message模块";

    @Resource
    private ShortMessageService shortMessageService;
    @Resource
    private MemberService memberService;

    @RequestMapping(value="/send",method = RequestMethod.POST)
    public ResponseDataDto sendShortMessage(@RequestBody ShortMessageDto shortMessageDto){
        ResponseDataDto responseData=new ResponseDataDto();
        responseData.setResponseData(shortMessageService.sendShortMessage(shortMessageDto));
        return responseData;
    }

    //验证手机号是否存在
    @RequestMapping("/mobileExist/{mobile}")
    public ResponseDataDto checkModileExist(@PathVariable String mobile){
        ResponseDataDto responseData=new ResponseDataDto();
        MemberDto memberDto=memberService.getMemberPhone(mobile);
        //为空在返回false不存在，可以发送验证码
        if(memberDto==null){
            responseData.setSuccess(false);
        }else{
            responseData.setSuccess(true);
        }
        return responseData;
    }

}
